<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
	<ui:composition template="/design/template.xhtml">
    <ui:define name="body">

      <h:form id="frmSimuladoModelo" acceptcharset="ISO-8859-1">
      <h:inputHidden id="codigoSimuladoModelo" value="#{adminSimuladoModeloAction.simulado.codigo}"/> 
      <p:panel id="pnlSimuladoModelo" header="Dados Simulado">

        <p:spacer height="10" />
        <p:messages id="messages" autoUpdate="true" />

        <h:panelGrid columns="3" cellpadding="4" >

          <h:outputText value="Identificação:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:inputText id="simuladoName" value="#{adminSimuladoModeloAction.simulado.identificacao}" style="width:250px;" 
                       required="true" requiredMessage="Identificação obrigatória!">
          </p:inputText>

          <h:outputText value="Descrição:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:inputText id="simuladoDescricao" value="#{adminSimuladoModeloAction.simulado.descricao}" style="width:250px;" 
                       required="true" requiredMessage="Descrição obrigatória!">
          </p:inputText>

          <h:outputText value="Instituição:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:selectOneMenu id="instituicaoSimuladoModelo" value="#{adminSimuladoModeloAction.simulado.instituicao.codigo}" 
                           style="width:257px;" >  
            <f:selectItem itemValue="" itemLabel="Selecione uma instituição"/>  
            <f:selectItems value="#{adminSimuladoModeloAction.instituicaoItems}"/>  
          </p:selectOneMenu>

          <h:outputText value="Orgão:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:selectOneMenu id="orgaoSimuladoModelo" value="#{adminSimuladoModeloAction.simulado.orgao.codigo}"  
                           style="width:257px;" >  
            <f:selectItem itemValue="" itemLabel="Selecione um orgão"/>  
            <f:selectItems value="#{adminSimuladoModeloAction.orgaoItems}"/>  
          </p:selectOneMenu>

          <h:outputText value="Nível:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:selectOneMenu id="nivelSimuladoModelo" value="#{adminSimuladoModeloAction.simulado.nivel.codigo}"   
                           style="width:257px;" >  
            <f:selectItem itemValue="" itemLabel="Selecione um nível"/>  
            <f:selectItems value="#{adminSimuladoModeloAction.nivelItems}"/>  
          </p:selectOneMenu>

          <h:outputText value="Situação:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:selectOneMenu id="simuladoSituacao" value="#{adminSimuladoModeloAction.simulado.situacao.codigo}" style="width:158px;" 
                           required="true" requiredMessage="Situação simulado obrigatoria!">  
            <f:selectItem itemValue="" itemLabel="Selecione uma situação"/>  
            <f:selectItems value="#{adminSimuladoModeloAction.situacaoItems}"/>  
          </p:selectOneMenu>

          <h:outputText value="Materias:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:dataTable id="tblMaterias" value="#{adminSimuladoModeloAction.simulado.listaSimuladoMaterias}" var="simuladoMateria" >
            <p:column>
              <p:spacer width="5" />
              <p:selectOneMenu id="materia" value="#{simuladoMateria.materia.codigo}" style="width:257px;" 
                               required="true" requiredMessage="Materia obrigatoria!">
                <f:selectItem itemValue="" itemLabel="Selecione uma materia"/>
                <f:selectItems value="#{adminSimuladoModeloAction.materiaItems}"/>
              </p:selectOneMenu>
              <p:spacer width="10" />
              <p:inputText id="quantidade" value="#{simuladoMateria.quantidadeQuestoes}" style="width:20px;" required="true" 
                requiredMessage="Quantidade de questões obrigatória!" maxlength="2">
              </p:inputText>
              <p:spacer width="5" />
            </p:column>
            <p:column>
              <p:commandLink id="lnkDeleteItem" update=":dlgConfirm" oncomplete="varDlgConfirm.show()" >
                <h:graphicImage value="/images/action_desabled.gif" width="16" height="16" style="border: 0px;" title="excluir materia" />
                <f:setPropertyActionListener value="#{simuladoMateria}" target="#{adminSimuladoModeloAction.simuladoMateria}" />            
              </p:commandLink>
            </p:column>
          </p:dataTable>

          <p:spacer width="1" />
          <p:spacer width="6" />
          <h:commandLink action="#{adminSimuladoModeloAction.adicionarMateria}" value="adicionar materia" style="width:350px;" />

        </h:panelGrid>
        <p:spacer height="10" />
        <p:outputPanel id="pnlButons">
          <div align="left" id="divButons">
            <p:commandButton action="#{adminSimuladoModeloAction.listar}" value="cancelar" ajax="false" immediate="true" />
            <p:spacer width="10" />
            <p:commandButton action="#{adminSimuladoModeloAction.incluir}" update="pnlSimuladoModelo" value="incluir" ajax="false" rendered="#{adminSimuladoModeloAction.acaoIncluir}" />
            <p:commandButton action="#{adminSimuladoModeloAction.alterar}" update="pnlSimuladoModelo" value="alterar" ajax="false" rendered="#{adminSimuladoModeloAction.acaoAlterar}" />
          </div>
        </p:outputPanel>			

    </p:panel>
    </h:form>

    <p:dialog widgetVar="varDlgConfirm" id="dlgConfirm" header="Confirmação" modal="true" resizable="false" draggable="false" width="250">
      <p:outputPanel id="pnlConfirm">  
      <table width="100%">
        <tbody>
          <tr>
            <td align="center" colspan="2" width="100%">
              <h:outputText value="Confirma excluir materia" ></h:outputText>
            </td>
          </tr>
          <tr>
            <td align="center" colspan="2" width="100%">
              <h:outputText style="font-weight:bold" value="#{adminSimuladoModeloAction.simuladoMateria.materia.nome}" ></h:outputText>
            </td>
          </tr>
          <tr>
            <td align="center" colspan="2" width="100%" height="10"></td>
          </tr>
          <tr>
            <td align="center" width="50%">
              <p:commandButton value="confirmar" action="#{adminSimuladoModeloAction.excluirMateria}" update=":frmSimuladoModelo:tblMaterias" oncomplete="varDlgConfirm.hide();" />
            </td>
            <td align="center" width="50%">
              <p:commandButton value="cancelar" onclick="varDlgConfirm.hide();" />
            </td>
          </tr>
        </tbody>
      </table>
      </p:outputPanel>
    </p:dialog>

  </ui:define>
  </ui:composition>
</html>
